Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Rewrite of Array.Copy fast path in C# #27634

Merged
merged 9 commits into from
Nov 3, 2019
Merged

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Nov 2, 2019

Contributes to #27106

@jkotas
Copy link
Member Author

jkotas commented Nov 2, 2019

This is greatly reducing the fixed Array.Copy overhead for common cases. E.g. Copying byte array of length one:

  • Array.Copy(Array, Array, int): 2.3x faster
  • Array.Copy(Array, int, Array, int, int): 1.5x faster

@jkotas
Copy link
Member Author

jkotas commented Nov 2, 2019

Also, this is fixing the performance penalty of the Array.Copy(Array, Array, int) overload for common cases. This overload is faster than the more verbose Array.Copy(Array, int, Array, int, int) one for the typical cases. We can switch the places that used to explicitly pass the start index as 0 to avoid this penalty back to the less verbose overload.

cc @stephentoub

@stephentoub
Copy link
Member

We can switch the places that used to explicitly pass the start index as 0 to avoid this penalty back to the less verbose overload.

Nice. I'm always a fan of both simpler and faster :) I can do so separately in corefx. Do you want to do it in corelib as part of this PR?

@jkotas
Copy link
Member Author

jkotas commented Nov 2, 2019

Do you want to do it in corelib as part of this PR?

My plan was to do that as follow up PR.

@jkotas jkotas requested a review from VSadov November 2, 2019 17:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants